from power import Power, Response, Request, Router


demo_app = Power()

book = Router("/book")


@demo_app.route('/')
async def test(request: Request):
    response = Response(f"<h1>终于跑起来了, 我在{request.host}</h1>", status=200)
    return response


@demo_app.route("/json")
async def json_test(request: Request):

    return {
        "test": "ok",
        "host": request.host
    }


@book.get("/sub")
async def sub(request: Request):

    return request


if __name__ == '__main__':
    demo_app.run()
